{% extends "skeleton.html" %}
{% import "forum/macros.html" as m %}

{% block header %}
  {{m.html_header(resource_version)}}
{% endblock %}
{% block pagetitle %}Forums{% endblock %}
{% block title %}Forums{% endblock %}

{% block maincontent %}
  <section class="content">
    <nav class="breadcrumbs">
      <ul>
        <li><a href="/">War Worlds</a>
        <li><span>Forums</span>
      </ul>
    </nav>

    <section class="blurb">
      <p>The War Worlds forums are a place to discuss various aspects of the game. I currently don't have a moderation
         policy or "rules" as such, I just ask that people try to stay on-topic and be polite. I think we can all be
         grown-ups here.</p>
      <p>If you enjoy the game, I would encourage you to log in using the same Google Account that you use to play the
         game, so that we can link your persona on the forums to your in-game Empire.</p>
    </section>

  <nav class="toolbar">
    <ul>
      <li class="search">
        <form action="/forum/search" method="get">
          <input type="text" name="q" placeholder="Search">
          <div class="input-button"><input type="submit" value="Search"></div>
        </form>
      </li>
    </ul>
  </nav>

  {% for forum in forums %}
    <div class="forum-entry">
      <div class="forum-title">
        <a href="/forum/{{forum.slug}}"><h2>{{forum.name}}</h2></a>
        <div>{{forum.description}}</div>
      </div>
      <div class="forum-stats">
        <div><span>{{post_counts[forum.slug]['threads'] if forum.slug in post_counts else '0'}}</span> threads</div>
        <div><span>{{post_counts[forum.slug]['posts'] if forum.slug in post_counts else '0'}}</span> posts</div>
      </div>
      <div class="last-post">
        {% if forum.slug in top_threads %}
          <div class="post-title"><a href="/forum/{{forum.slug}}/{{top_threads[forum.slug].slug}}">{{top_threads[forum.slug].subject}}</a></div>
          <div class="post-author">
            by <a href="{{m.profile_url(top_thread_user_profiles[top_threads[forum.slug].user.user_id()])}}"><img src="{{top_thread_user_profiles[top_threads[forum.slug].user.user_id()]|profile_shield}}" width="16" height="16"/>
            {{top_thread_user_profiles[top_threads[forum.slug].user.user_id()].display_name}}</a>
          </div>
          <time datetime="{{top_threads[forum.slug]|post_date_std}}" class="post-date">{{top_threads[forum.slug]|post_date_time}}</time>
        {% endif %}
      </div>
      <div class="last"></div>
    </div>
  {% endfor %}
  </section>
{% endblock %}